package ch.trackedbean.client;

import java.rmi.registry.*;
import ch.trackedbean.server.*;

/**
 * Helper class for accessing the RMI service.
 * 
 * @author hautle
 */
public class ServerAccess {
	/** Singeleton. */
	public static ServerAccess ME = new ServerAccess();

	/** The reference to the server. */
	private final Server srv;

	/**
	 * Default construcotr.
	 */
	private ServerAccess() {
		try {
			final Registry registry = LocateRegistry.getRegistry();
			srv = (Server) registry.lookup(Server.NAME);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	/**
	 * @return The server access
	 */
	public Server getSrv() {
		return srv;
	}
}
